package third;


import java.util.Scanner;

public class third_21 {
    public static void main(String[] args) {
		int m,y,d;
		Scanner input = new Scanner(System.in);
		System.out.print("Enter year:");
		y=input.nextInt();
		System.out.print("Enter month:");
		m=input.nextInt();
		System.out.print("Enter day of month:");
		d=input.nextInt();
		if(m<3) {
			m+=12;
			y-=1;
		}
		int k=y%100;
		int j=y/100;

		int h=(d + (26*(m+1)/10)+k+k/4+j/4+5*j)%7;

		if(h==0) {
			System.out.println("Day of the week is Saturday");
		}
		else if (h==1) {
			System.out.println("Day of the week is Sunday");
		}
		else if (h==2) {
			System.out.println("Day of the week is Monday");
		}
		else if (h==3) {
			System.out.println("Day of the week is Tuesday");
		}
		else if (h==4) {
			System.out.println("Day of the week is Wednesday");
		}
		else if (h==5) {
			System.out.println("Day of the week is Thursday");
		}
		else if (h==6) {
			System.out.println("Day of the week is Friday");
		}



    }
}
